﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace AKBGame.Util
{
    public class XMLHelper
    {
        public static void SaveToXML<T>(T list, string output)
        {
            XmlSerializer serialiser = new XmlSerializer(typeof(T));
            TextWriter FileStream = new StreamWriter(output);
            serialiser.Serialize(FileStream, list);
            FileStream.Close();
        }

        public static T LoadFromXML<T>(string input)
        {
            string xml = File.ReadAllText(input);

            using (StringReader stringReader = new StringReader(xml))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(T));
                return (T)serializer.Deserialize(stringReader);
            }
        }
    }
}
